#include "InetIpv4Test.h"


#include "Pacap/InetIpv4.h"

using namespace Pacap;

void InetIpv4Test::SetUpTestCase()
{
    std::cout << "开始InetIpv4Test单元测试" << std::endl;
}

void InetIpv4Test::TearDownTestCase()
{
    std::cout << "结束InetIpv4Test单元测试" << std::endl;
}


TEST_F(InetIpv4Test,unpack){
    static const unsigned char pkt38[57] = {
    0x00, 0x0c, 0x29, 0xb9, 0x8c, 0x55, 0x44, 0x1c, /* ..)..UD. */
    0xa8, 0xe2, 0x1c, 0xcd, 0x08, 0x00, 0x45, 0x00, /* ......E. */
    0x00, 0x2b, 0x1c, 0xbd, 0x40, 0x00, 0x80, 0x06, /* .+..@... */
    0x51, 0xf2, 0xc0, 0xa8, 0x05, 0x68, 0xc0, 0xa8, /* Q....h.. */
    0x05, 0x65, 0xdf, 0x53, 0xc3, 0x51, 0x7b, 0x8d, /* .e.S.Q{. */
    0x4d, 0xcc, 0x83, 0x83, 0xf6, 0x56, 0x50, 0x18, /* M....VP. */
    0x08, 0x05, 0xd1, 0x9a, 0x00, 0x00, 0x31, 0x32, /* ......12 */
    0x33                                            /* 3 */
    };

    PackType hexData( (uint8_t*)pkt38+14,57-14 );
    InetIpv4 parser;
    parser.unpack(hexData);

    ASSERT_EQ( 43, parser.getIpLen() );
    std::cout << parser.getData().toString() << std::endl;
}
